<div class="row row-cards row-deck">
  <div class="col-2">
    <div class="card">
      <div class="card-body">
        <div class="form-group">
          <label class="form-label">订单处理</label>
          <div class="form-control-plaintext">
            <div><%= link_to "全部", shop_orders_path %></div>
            <% Order.states.keys.each do |state| %>
              <div><%= link_to "#{I18n.t("order.state.#{state.downcase}")}", request.parameters.merge({state: state}) %></div>
            <% end %>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="col-10">
    <div class="card">
      <div class="card-header">
        <%= link_to "今天", request.parameters.merge({between: "today"}), style: "margin-right: 20px;", class:"btn btn-pill btn-warning" %>
        <%= link_to "本周", request.parameters.merge({between: "by_week"}), style: "margin-right: 20px;", class:"btn btn-pill btn-warning" %>
        <%= link_to "本月", request.parameters.merge({between: "by_month"}), style: "margin-right: 20px;", class:"btn btn-pill btn-warning" %>
      </div>
      <table class="table table-hover table-outline table-vcenter text-nowrap card-table">
        <thead>
          <tr>
            <th>订单编号</th>
            <th>总价</th>
            <th>下单用户</th>
            <th>下单电话</th>
            <th>付款方式</th>
            <th>订单状态</th>
            <th class="text-center">
            </th>
          </tr>
        </thead>
        <tbody>
          <% @orders.each do |order| %>
            <tr>
              <td>
                <div><%= order.trade_no %></div>
                <div class="small text-muted">
                  <%= formattime(order.created_at, unit: "hour") %>
                </div>
              </td>
              <td>
                <div><%= order.total_fee %></div>
              </td>
              <td>
                <div><%= order.user.blank? ? "用户已删除" : order.user.nickname %></div>
              </td>
              <td>
                <div><%= order.user.blank? ? "用户已删除" : order.user.phone %></div>
              </td>
              <td>
                <div><%= i18n_enum order, :pay_method %></div>
              </td>
              <td>
                <div>
                  <span class="status-icon bg-success"></span>
                  <%= i18n_enum order, :state %>
                </div>
              </td>
              <td class="text-center">
                <div class="item-action dropdown">
                  <a href="javascript:void(0)" data-toggle="dropdown" class="icon"><i class="fe fe-more-vertical"></i></a>
                  <div class="dropdown-menu dropdown-menu-right">
                    <% if order.sent? %>
                    <a href="<%= shop_order_express_tracks_path(order) %>" class="dropdown-item"><i class="dropdown-icon fe fe-tag"></i> 物流信息 </a>
                    <% end %>
                    <a href="<%= edit_shop_order_path(order) %>" class="dropdown-item"><i class="dropdown-icon fe fe-tag"></i> 修改 </a>
                    <%= link_to shop_order_path(order), method: :delete, class: 'dropdown-item' do %>
                      <i class="dropdown-icon fe fe-edit-2"></i> 删除 
                    <% end %>
                  </div>
                </div>
              </td>
            </tr>
          <% end %>
        </tbody>
      </table>
      <div class="card-footer">
        <%= paginate @orders %>
      </div>
    </div>
  </div>
</div>